/*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

FIVe3D
Flash Interactive Vector-based 3D
Mathieu Badimon  |  five3d@mathieu-badimon.com

http://five3D.mathieu-badimon.com  |  http://five3d.mathieu-badimon.com/archives/  |  http://code.google.com/p/five3d/

/*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

import net.badimon.five3D.display.Sprite;

class net.badimon.five3D.display.Scene {

	public var __clip:MovieClip;
	private var __renderer:MovieClip;
	private var __root:Sprite;
	private var __viewdistance:Number = 1000;
	public var __render:Boolean = true;

	function Scene(clip:MovieClip) {
		__clip = clip;
		createRenderer();
		__root = new Sprite(this, __clip, "root", 0, undefined);
	}

	private function createRenderer(Void):Void {
		var ref:Scene = this;
		__renderer = _root.createEmptyMovieClip("renderer", 10000);
		__renderer.onEnterFrame = function():Void {
			if (ref.__render) ref.render();
		};
	}

	public function render(Void):Void {
		__root.render();
		__render = false;
	}

	public function getRoot():Sprite {
		return __root;
	}

	public function get _viewdistance():Number {
		return __viewdistance;
	}

	public function set _viewdistance(value:Number):Void {
		__viewdistance = value;
		__render = true;
		__root.askRendering();
	}
}